// 对称数

function findPalindromeNumbers1(max: number): number[] {
    const res: number[] = []
    if (max <= 0) return res
    for (let i = 1; i <= max; i++) {
        const s = i.toString()
        if (s === s.split('').reverse().join('')) {
            res.push(i)
        }
    }
    return res
}
function findPalindromeNumbers2(max: number): number[] {
    const res: number[] = []
    if (max <= 0) return res
    for (let i = 1; i <= max; i++) {
        const s = i.toString()
        let flag = true
        const length = s.length
        let startIndex= 0;
        let endIndex = length - 1
        while(startIndex < endIndex) {
            if(s[startIndex] !== s[endIndex]) {
                flag = false
                break
            } else {
                startIndex++
                endIndex--
            }
        }
        if(flag) res.push(i)
    }
    return res
}
console.log(findPalindromeNumbers2(100));
